#!/bin/bash
# script to remove symbol collisions between cryptlib and openssl
#
# Author:  Ralf Senderek
# Date:    15 July 2016
# License: BSD
#
# this script must be run in the cryptlib directory before building the
# shared library

for F in $(find . -type f)
do
    sed -i 's/BN_/cl_BN_/g' $F
    sed -i 's/bn_/cl_bn_/g' $F
    sed -i 's/CAST_/cl_CAST_/g' $F
    sed -i 's/MD5_/cl_MD5_/g' $F
    sed -i 's/SHA1_/cl_SHA1_/g' $F
    sed -i 's/sha1_block/cl_sha1_block/g' $F
    sed -i 's/idea_/cl_idea_/g' $F
done

# rename RC4 to cl_RC4

sed -i 's/RC4(/cl_RC4(/g' context/ctx_rc4.c
sed -i 's/RC4(/cl_RC4(/g' crypt/rc4.h
sed -i 's/RC4(/cl_RC4(/g' crypt/rc4enc.c

cd bn
for F in $(ls bn_*)
do
     mv $F cl_$F
done

#------------------------------------------------------------------#
